<?php
include_once ('class/autoload.php'); // pour inclure nos classes
include_once ('class/config.inc.php');
$site = new page_securisee ( 'accueil', "Gestion des Mother fucking techniciens", "Tous des cons" );

$corps = '<div role="tabpanel">
<ul class="nav nav-tabs" role="tablist" id="myTab">
    <li role="presentation" class="active"><a href="#ajout" aria-controls="ajout" role="tab" data-toggle="tab">Ajout</a></li>
    <li role="presentation"><a href="#modif" aria-controls="modif" role="tab" data-toggle="tab">Modification</a></li>
	<li role="presentation"><a href="#suppr" aria-controls="suppr" role="tab" data-toggle="tab">Suppression</a></li>
</ul>
<div class="tab-content">
    <div role="tabpanel" class="tab-pane active" id="ajout">
		<form method="post" action="gestTech.php" id="inscription">
        	<h2 class="form-signin-heading">Ajouter un technicien</h2>
        	<input type="text" class="input-block-level" placeholder="Nom" name="nomNouvTech"><br />
       		<input type="text" class="input-block-level" placeholder="Mot de passe" name="mdpNouvTech"><br />
        	<button class="btn btn-large btn-success" type="submit" value="Valider">Ajouter le client</button>
		</form>
	</div>
	<div role="tabpanel" class="tab-pane" id="modif">
	<form action="gestTech.php" method="post">
		<h2 class="form-signin-heading">Modifiez le mot de passe d\'un technicien </h2>
	<p>Selectionner le technicien pour lequel vous désirez modifier le mot de passe :</p>
	<select name= "tech">
		<option selected></option>' . affiche_Tech () . '</select><br>
			<input type="submit" class="btn btn-large btn-primary" value="Modifier le mot de passe">
				</form>
	</div>

	<div role="tabpanel" class="tab-pane" id="suppr">
		<form method="post" action="gestTech.php">
        	<h2 class="form-signin-heading">Supprimer un technicien</h2>
			<p>Selectionner le technicien que vous voulez supprimer :</p>
			<select name= "supprtech">
		<option selected></option>' . affiche_Tech () . '</select><br>
        		<button class="btn btn-large btn-danger" type="submit" value="Valider">Supprimer le technicien</button>
		</form>
	</div>
</div>';
if (isset ( $_POST ['nomNouvTech'] ) && isset ( $_POST ['mdpNouvTech'] )) {
	$type = "1";
	add_util ( $_POST ['nomNouvTech'], $_POST ['mdpNouvTech'], $type );
}
if (isset ( $_POST ['tech'] )) {
	$corps = '<form action="gestTech.php" method="post">
	<p>Entrez le nouveau mot de passe pour ce technicien :</p>
			<input type="hidden" name="idTech" value="' . $_POST ['tech'] . '">
	<input type="password" class="input-block-level" placeholder="Nouveau mot de passe" name="mdpNouvTech"><br />
	<input type="submit" class="btn btn-large btn-primary" value="Modifier le mot de passe">';
}
if (isset ( $_POST ['mdpNouvTech'] )) {
	
	if (empty ( $_POST ['mdpNouvTech'] )) {
		$corps = '<p>Valeur impossible.<p>
				<a href="gestTech.php"> <input type="button"  class="btn btn-large btn-primary" value="Retour">';
	} else {
		$corps = "<h2>Item bien modifié</h2>";
		
		change_pwd ( $_POST ['idTech'], $_POST ['mdpNouvTech'] );
		$corps .= '<br><a href="ModifierLibellePro.php" > <input type="button" class="btn btn-large btn-primary" value="Modifier une autre problématique">  </a><a href="AccueilConnecter.php" > <input type="button" class="btn btn-large btn-primary" value="Accueil">  </a>';
	}
}
if (isset ( $_POST ['supprtech'] )) {
	supp_compte ( $_POST ['supprtech'] );
	$corps = '<p>Technicien supprimé.<p>
				<a href="gestTech.php"> <input type="button"  class="btn btn-large btn-primary" value="Retour">';
}

$site->corps = $corps;
$site->affiche ();
?>